﻿using System.Collections.Generic;
using System.Linq;

namespace Sern.Common
{
    /// <summary>
    /// The repository for a collection of type U.
    /// </summary>
    /// <typeparam name="U"></typeparam>
    public interface IRepository<U>
    {
        /// <summary>
        /// Retrieves a queriable collection of type U.
        /// </summary>
        /// <returns></returns>
        IQueryable<U> Records { get; }

        /// <summary>
        /// Adds a set of U to the repository.
        /// </summary>
        /// <param name="set"></param>
        void AddMany(IEnumerable<U> set);

        /// <summary>
        /// Adds a single member to the repository.
        /// </summary>
        /// <param name="entity"></param>
        void Add(U entity);

        /// <summary>
        /// Deletes many member from the repository.
        /// </summary>
        /// <param name="set"></param>
        void DeleteMany(IEnumerable<U> set);

        /// <summary>
        /// Deletes a single member from the repository.
        /// </summary>
        /// <param name="entity"></param>
        void Delete(U entity);

        /// <summary>
        /// Persist the repository to the database.
        /// </summary>
        void Save();


        /// <summary>
        /// Apply changes.
        /// </summary>
        /// <param name="set"></param>
        void UpdateMany(IEnumerable<U> set);

        /// <summary>
        /// Apply changes.
        /// </summary>
        /// <param name="set"></param>
        void Update(U entity);
    }
}
